// pages/mettingPlace/mettingPlace.js

Page({
  data: {
    mp_brand_item: [{ img: '', name: '耐克官方旗舰店', ident:'../../img/nike-logo.png'},
      { img: '', name: '耐克官方旗舰店', ident: '' },
      { img: '', name: '耐克官方旗舰店', ident: '' },
      { img: '', name: '耐克官方旗舰店', ident: '' },
      { img: '', name: '耐克官方旗舰店', ident: '' },
      { img: '', name: '耐克官方旗舰店', ident: '' }],
    mp_bg_swiper_item: [{ isBig: false, img: '../../img/service3.png', name:"美妆会场"},
      { isBig: false, img: '../../img/service3.png', name: "美妆会场"}, 
      { isBig: false, img: '../../img/service3.png', name: "美妆会场" }, 
      { isBig: false, img: '', name: "美妆会场"}, 
      { isBig: false, img: '../../img/service3.png', name: "美妆会场"},
      { isBig: false, img: '../../img/service4.png', name: "美妆会场" },
      { isBig: false, img: '', name: "美妆会场"}, 
      { isBig: false, img: '', name: "美妆会场"}],
    mp_coupon_item: [{ num: 100, num2: 1000, range: '全场通用', other: '部分酒品除外', text: '点击领取', isGet: true,},
      { num: 50, num2: 500, range: '酒品可用', other: '部分商品除外', text: '点击领取', isGet: true, },
      { num: 10, num2: 100, range: '全场通用', other: '', text: '点击领取', isGet: true,},
      { num: 100, num2: 1000, range: '全场通用', other: '部分酒品除外', text: '点击领取',isGet: true,},]
  },
  getCoupon:function(e){
    var that = this;
    console.log(e.currentTarget.dataset.id)
    var id = e.currentTarget.dataset.id;
    let text = 'mp_coupon_item[' + id+ '].text';
    let isGet = 'mp_coupon_item[' + id + '].isGet';
    that.setData({
      [text]:'领取完毕',
      [isGet]:false
    });
    wx.showToast({
      title: '领取成功！',
    })
  },
  onShow: function () {
    //什么时候触发倒计时，就在什么地方调用这个函数
    this.countDown();
  },
  countDown: function () {
    let that = this;
    var id =0;
    that.setData({
      timer1: setInterval(function () {
        id++;
        let isBig = 'mp_bg_swiper_item[' + (id - 1) + '].isBig';
        let isNoBig = 'mp_bg_swiper_item[0].isBig';
        if(id>=2){
          isNoBig = 'mp_bg_swiper_item[' + (id - 2) + '].isBig';
        }
        if (id == (that.__data__.mp_bg_swiper_item.length)){
          // clearInterval(that.data.timer1); 
          id = id - that.__data__.mp_bg_swiper_item.length
        }
        that.setData({
          [isNoBig]:false,
          [isBig]: true,
        })
      }, 3000),
    })
    console.log()
  }
})